//
//  MeetingViewController.h
//  Rongcloud
//
//  Created by LiuLinhong on 2017/08/09.
//  Copyright © 2017年 Beijing Rongcloud Network Technology Co. , Ltd. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import <AVFoundation/AVFoundation.h>
#import <RongRTCLib/RongRTCEngine.h>
#import "MeetingRongRTCEngineDelegateImpl.h"
#import "MeetingViewBuilder.h"
#import "LeftMVControlCollectionViewDelegateSource.h"
#import "RightMVTableViewDelegateSource.h"
#import "MeetingSwitchPageViewDelegateSource.h"
#import "MeetingVideoViewModel.h"
#import "WhiteBoardWebUIDelegateImpl.h"
#import "AVDataInfoTableViewDelegateSource.h"
#import "MeetingLocalDataInfoModel.h"
#import "MeetingMemberDataInfoModel.h"
#import "MeetingWindowDelegateImpl.h"
#import "HeadIconView.h"
#import "NSColor+ColorChange.h"
#import "MeetingManager.h"

#define kUserID          @"userId"
#define kUserName        @"userName"
#define kRemoteVideoView @"remoteVideoView"
//#define kUserType        @"userType"
#define kAudioVideoType  @"audioVideoType"
#define kSwitchHeadIcon  @"switchHeadIcon"
#define kMicphoneImage   @"micphoneImage"
#define kHeaderImage     @"HeaderImage"
#define kVideoWidth 640
#define kVideoHeight 480
#define kCellSize 80
#define kCellAudioViewHeight 20
#define kScreenWidth [NSScreen mainScreen].frame.size.width
#define kScreenHeight [NSScreen mainScreen].frame.size.height

typedef NS_ENUM(NSInteger, RongRTCMessageType)
{
    RongRTC_Message_Join = 0,
    RongRTC_Message_Leave = 1,
    RongRTC_Message_Upgrade = 2,
    RongRTC_Message_Degrade = 3,
    RongRTC_Message_WhiteBoard = 4,
    RongRTC_Message_StartScreenShare = 5,
    RongRTC_Message_StopScreenShare = 6,
    RongRTC_Message_Host = 7,
    RongRTC_Message_Alone = 8
};

typedef void (^MessageAlertBlock)(BOOL selected);
typedef void (^ApplyRequestBlock)(BOOL isAccept);

@interface MeetingViewController : NSViewController <RongRTCEngineDelegate>

@property (strong) IBOutlet NSView *mainView;
@property (nonatomic, strong) RongRTCEngine *rongRTCEngine;
@property (nonatomic, strong) NSString *channelID, *userID, *userName;
@property (nonatomic, strong) MeetingRongRTCEngineDelegateImpl *meetingRongRTCEngineDelegateImpl;
@property (nonatomic, strong) MeetingViewBuilder *meetingViewBuilder;
@property (nonatomic, strong) MeetingSwitchPageViewDelegateSource *meetingSwitchPageViewDelegateSource;
@property (nonatomic, strong) LeftMVControlCollectionViewDelegateSource *leftMVControlCollectionViewDelegateSource;
@property (nonatomic, strong) RightMVTableViewDelegateSource *rightMVTableViewDelegateSource;
@property (nonatomic, strong) WhiteBoardWebUIDelegateImpl *whiteBoardWebUIDelegateImpl;
@property (nonatomic, strong) MeetingWindowDelegateImpl *meetingWindowDelegateImpl;

@property (nonatomic, strong) NSMutableDictionary *paraDic;

@property (nonatomic, strong) MeetingVideoViewModel *localVideoViewModel, *selectedViewModel;

@property (nonatomic, strong) dispatch_semaphore_t semaphore;

@property (nonatomic, strong) NSString *requestUpgradeUserID;
@property (nonatomic, strong) AVDataInfoTableViewDelegateSource *avDataInfoTableViewDelegateSource;
@property (nonatomic, strong) NSTimer *durationTimer;
@property (nonatomic, assign) NSUInteger duration;

- (void)joinChannel;
- (void)leaveChannel;
- (void)loadLocalVideoView;
- (void)modifyAudioVideoType;
- (void)updateAudioVideoType:(RongRTCAudioVideoType)type;

- (void)leftScrollButtonPressed;
- (void)rightScrollButtonPressed;
- (void)downVideosBottomButtonPressed;
- (void)hideControlViewButtonPressed;

- (void)requestSpeakButtonPressed;
- (void)inviteButtonPressed;
- (void)manageMeetingButtonPressed;
- (void)useWhiteBoardButtonPressed;
- (void)shareScreenButtonPressed;
- (void)videoRecordButtonPressed;
- (void)closeCameraButtonPressed;
- (void)muteButtonPressed;
- (void)hungupButtonPressed;

- (void)leftMessageButtonPressed;
- (void)rightMemberButtonPressed;
- (void)leftMVVoiceButtonPressed;
- (void)leftMVSendButtonPressed;

- (void)modifySignalLevel:(NSInteger)level;
- (void)startCallingBreath:(NSString *)userID block:(ApplyRequestBlock)block;
- (void)stopCallingBreath;
- (void)endBreathTimerAction;
- (void)controlMemberMicphone:(NSString *)userID status:(BOOL)isOpen;
- (void)controlMemberCamera:(NSString *)userID status:(BOOL)isOpen;
- (void)degradeMemberToObserver:(NSString *)userID;
- (void)upgradeMemberToNormal:(NSString *)userID;
- (void)removeAttendedMember:(NSString *)userID;
- (void)callingHungUpButtonPressed;
- (void)callingAcceptButtonPressed;
- (void)showMessageAlert:(NSString *)textField title:(NSString *)title completedBlock:(MessageAlertBlock)block;
- (void)showMessageAlertSingle:(NSString *)textField title:(NSString *)title;
- (void)messageAlertYes;
- (void)messageAlertNo;
- (void)messageAlertSingleYes;
- (void)addTipMsg:(NSString *)userName withMessageType:(RongRTCMessageType)type;

- (void)transformToFullScreen;
- (void)transformToOriginalSize;

- (void)updateTalkTimeLabel;
- (void)dataInfoButtonPressed;
- (void)exchangeVideoSizeButtonPressed;

- (void)restoreCloseCameraState;
- (void)restoreMuteState;
- (void)reminderUserDeviceStatus;

@end
